'''
Created on Apr 23, 2012
TC ID: Ecom_5023
Desc: Kiem thu chuc nang tim kiem nhom nguoi dung
@author: lavang
'''
import unittest
from HTMLTestRunner import HTMLTestRunner
import time
from Functions.loginPageFunc import login
from Functions.globalFunc import readData, preCondition, endCondition
from Functions.userGroupsFunc import clickOnUserGroups,\
    searchUserGroup, isUserGroupSearch

username=readData("username")
password=readData("password")
tm_userGroupName=readData("groupName",index=3)
class Ecom_5023(unittest.TestCase):


    def setUp(self):
        preCondition(self)

    def test_Ecom_5023(self):
        print "Buoc 1: Dang nhap vao website"
        login(self,username,password)
        
        print "Buoc 2: Click vao User groups"
        clickOnUserGroups(self)
        
        print "Buoc 4: Nhap ten group da co vao o filter, thuc hien tim kiem"
        searchUserGroup(self,tm_userGroupName)
        
        print "Buoc 5: Kiem tra group ton tai"
        self.assertTrue(isUserGroupSearch(self,tm_userGroupName), "Khong tim thay nhom nguoi dung!")
        print "Passed: Nhom nguoi dung ton tai"
 
    def tearDown(self):
        endCondition(self)



if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    testSuite = unittest.TestSuite()
    suite = unittest.TestLoader().loadTestsFromTestCase(Ecom_5023)
    dateTime = time.strftime('%Y%m%d_%H_%M_%S')
    buf = file("../../Report/TestResults" + "_" + dateTime + ".html",'wb')
    runner = HTMLTestRunner(
                    stream=buf,
                    title='Test Results',
                    description='Kiem thu chuc nang tim kiem nhom nguoi dung'
                    )
    runner.run(suite)